<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const obj1 = {
            a: {
                uname: 'zhangsan',
            }
        };
        const obj2 = {
            b: {
                uname: 'lisi',
            }
        };

        // es5
        // const obj = Object.assign({}, obj1, obj2)
        // obj.a = {
        //     uname: 'zhangsan2',
        // }
    
        // obj.a.uname = 'zhangsan1';
        // console.log(obj1.a.uname);


        // es6
        const obj = {
            ...obj1,
            ...obj2,
        }
        obj.a.uname = 'zhangsan1';
        obj.b.uname = 'lisi1';
        console.log(obj1.a.uname); // 'zahngsan1'
        console.log(obj2.b.uname);// 'lisi1'
    </script>
</body>

</html>